interface Person {
    name: string;
    age: number;
  }
  
  type ReadonlyPerson = {
    readonly [P in keyof Person]: Person[P];
  };
  
  const user22:ReadonlyPerson={
    name: 'ss',
    age: 12
  }
  // user22.name='ii'  //会报错
  
  
  // 2、
  // interface Person {
  //   // age:number
  //   id: number;
  //   name: string;
  //   email: string;
  // }
  
  // const userr3: Readonly<Person> = {
  //   // age:2,
  //   id: 1,
  //   name: "Dolphin",
  //   email: "dolphin@meituan.com"
  // };
  
  // // 尝试修改只读属性会导致编译错误
  // // user.id = 2; // Error: Cannot assign to 'id' because it is a read-only property.
  // // user.name = "Bob"; // Error: Cannot assign to 'name' because it is a read-only property.
  